﻿using System;
namespace Producers.Taitis.Xtee.Riik.Ee.Producer.Taitis {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="noue3", Namespace="http://producers.taitis.xtee.riik.ee/producer/taitis", Target=typeof(Noue3))]
    public class Noue3Serializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected INoue3 clazz;
        
        public Noue3Serializer(INoue3 clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("liik");
            if (clazz.Liik!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Liik))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Liik");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("sisu");
            if (clazz.Sisu!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Sisu))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Sisu");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("suurus");
            if (clazz.Suurus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Suurus))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Suurus");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("jaak");
            if (clazz.Jaak!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Jaak))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Jaak");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("olek");
            if (clazz.Olek!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Olek))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Olek");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "liik")) {
                goto liik;
            }
            else {
                if ((Reader.LocalName == "sisu")) {
                    goto sisu;
                }
                else {
                    if ((Reader.LocalName == "suurus")) {
                        goto suurus;
                    }
                    else {
                        if ((Reader.LocalName == "jaak")) {
                            goto jaak;
                        }
                        else {
                            if ((Reader.LocalName == "olek")) {
                                goto olek;
                            }
                            else {
                                return;
                            }
                        }
                    }
                }
            }
        liik:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>noue3>liik");
            }
            clazz.Liik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("liik")).Value;
            goto START;
        sisu:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>noue3>sisu");
            }
            clazz.Sisu = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("sisu")).Value;
            goto START;
        suurus:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>noue3>suurus");
            }
            clazz.Suurus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("suurus")).Value;
            goto START;
        jaak:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>noue3>jaak");
            }
            clazz.Jaak = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("jaak")).Value;
            goto START;
        olek:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>noue3>olek");
            }
            clazz.Olek = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("olek")).Value;
            goto START;
        }
    }
}
